<?php

include('includes/basic.php');
$clientid=$_POST['clid'];
$clientname=$_POST['cname'];
$clientdesc=addslashes($_POST['cdesc']);
$uname=$_POST['uname'];
$pass=md5($_POST['password']);
$cliusertypeid=$_POST['usertypeid'];
//$clienttpe=$_POST['clienttpe'];
		if($_POST['type']=='Active')
		{
			$clienttpe="A";
		}
		else 
		{
			$clienttpe="P";
		}
//$recordstatus=$_POST['recordstatus'];

		/*if($_POST['recordstatus']=='Yes')
		{
			$recordstatus="Y";
		}
		else 
		{
			$recordstatus="N";
		}*/


	$sql="update client_master set client_name='$clientname',client_description='$clientdesc',user_name='$uname',password='$pass',client_type='$clienttpe' where client_id=$clientid";
	$sql_res=mysql_query($sql);



if(isset($_POST['submit']) && $_FILES['uploadedfile']['size'] > 0)
			{

				$fileName = $_FILES['uploadedfile']['name'];
				$tmpName = $_FILES['uploadedfile']['tmp_name'];
				$fileSize = $_FILES['uploadedfile']['size'];
				$fileType = $_FILES['uploadedfile']['type'];
				
				$fp      = fopen($tmpName, 'r');
				$content = fread($fp, filesize($tmpName));
				$content = addslashes($content);
				fclose($fp);
				
				if(!get_magic_quotes_gpc())
				{
					$fileName = addslashes($fileName);
				}
				$check = mysql_query("select * from client_logo where client_id='$cliusertypeid'");
				if(mysql_num_rows($check)>0)
				{
				$query = "update client_logo set name='$fileName', size='$fileSize', type='$fileType', content='$content', uploaded_on=sysdate() where client_id='$cliusertypeid'";
				}
				else
				{
				$query = "INSERT INTO client_logo (client_id,name, size, type, content, uploaded_on) VALUES ('$cliusertypeid','$fileName', '$fileSize', '$fileType', '$content', sysdate())";
				}

				mysql_query($query) or die('Error, query failed'); 

				
			}

	
	if($sql_res)
	{
	
		header("location:view-clients.php");
	}
	
?>


